#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：python_learning 
@File ：汽车类_封装继承多态练习.py
@IDE  ：PyCharm 
@Author ：李涵彬
@Date ：2024/12/29 12:00 
"""


class Car:
	def __init__(self, name, color):
		self.name = name
		self.color = color

	def run(self):
		print("这是父类方法")
		print("{}在跑".format(self.name))


class Bmw(Car):
	def __init__(self, name, color, price):
		super().__init__(name, color)
		self.price = price

	def run(self):
		print("这是子类方法")
		print("{}在跑".format(self.name))


class Benz(Car):
	def __init__(self, name, color, price):
		super().__init__(name, color)
		self.price = price

	def run(self):
		print("这是子类方法")
		print("{}在跑".format(self.name))


# 实例化父类
c1 = Car("奔驰", "黑色")

# 实例化子类
c2 = Bmw("宝马", "白色", 200000)
c3 = Benz("奔驰", "黑色", 100000)

# 调用方法
c1.run()
c2.run()
c3.run()

# 输出结果
# 奔驰在跑
# 宝马在跑
# 奔驰在跑
